extends Node2D
export var max_resource = 10.0
var resource
var percentage=0.0
# Declare member variables here. Examples:
# var a = 2
# var b = "text"


# Called when the node enters the scene tree for the first time.
func _ready():
	max_resource += randi() % int(max_resource) - max_resource/2
	resource = max_resource
	#print(filename)
	pass # Replace with function body.


func _draw():
	#print(name, "_draw() called")
	draw_circle(Vector2(0,0),8,Color.greenyellow)
	draw_arc(Vector2(0,0), 12, -0.5 * PI, -(2 * PI * percentage + 0.5 * PI), 32 * percentage, Color.greenyellow, 4, true)
	
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	percentage = resource / max_resource
	#print(str(resource), "/", str(max_resource), "=",str(percentage))
	#_draw()
	update()
	#$Label.text = "food:" + str(resource)
	if resource <= 0:
		queue_free()
#	pass
